/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package slicktemplate;

import java.util.ArrayList;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.Image;
import org.newdawn.slick.Input;
import org.newdawn.slick.state.StateBasedGame;

/**
 *
 * @author andrew
 */
public class LevelEditButton implements Updateable, Renderable {

    public static ArrayList<LevelEditButton> all = new ArrayList<LevelEditButton>(); //arraylist to hold all PlayButtons
    int x, y, width, height;
    Image sprite;

    LevelEditButton(int x, int y) {
        all.add(this); //add this instance to the list of PlayButtons
        try {
            sprite = new Image("sprites/lvbutton.png"); //load the sprite
        } catch (Exception e) {
            e.printStackTrace();
        }
        this.x = x;
        this.y = y;
    }

    public boolean update(Input input, StateBasedGame sb) {
        int mouseX = input.getMouseX();
        int mouseY = input.getMouseY();
        if (input.isMouseButtonDown(Input.MOUSE_LEFT_BUTTON)) {
            if (checkIfClicked(mouseX, mouseY)) {
                sb.enterState(Game.LEVELEDIT_STATE);
            }
        }
        return false;
    }

    //checks if the mouse is in the bounding box, will probably be changed when formal collisions are added
    private boolean checkIfClicked(int mouseX, int mouseY) {
        if (x < mouseX && mouseX < x + sprite.getWidth() && y < mouseY && mouseY < y + sprite.getHeight()) {
            return true;
        }
        return false;
    }

    @Override
    public void render(Graphics g) {
        sprite.draw(x, y); //draw sprite
    }

    public String toString() {
        return "LVBUTTTRIANGLEN";
    }

    
    public boolean  mousePressed(Input input,StateBasedGame sb,int button) {
        return false;

    }
    public boolean  mouseDown(Input input, StateBasedGame sb, int button) {
        return false;
    }
    public void mousePressed(StateBasedGame sb, int button) {

    }

    @Override
    public float getX() {
        return x;
    }

    @Override
    public float getY() {
        return y;
    }

}
